package org.muyun.controllers;

import lombok.extern.slf4j.Slf4j;
import org.muyun.bean.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName MessageController
 * @Author 沐昀
 * @Description TODO
 * @date 2022/9/25 18:24
 */
@Slf4j
@RestController
public class MessageController {

    @RequestMapping("/hello")
    public String getMessage(@RequestParam("name") String name){

        log.info("请求进来了......");
        return "hello huiman" + "|你好：" + name;
    }

    //测试动态资源是否先于静态资源访问
    @RequestMapping("/bug.png")
    public String getBug(){
        return "This is bug!";
    }

    //
    @RequestMapping("/index")
    public String index(){
        return "index";
    }


    @Autowired
    Car car;
    @RequestMapping("/car")
    public Car car(){
        return car;
    }

    //获取用户 GET
    //@RequestMapping(value = "/user",method = RequestMethod.GET)
    @GetMapping("/user")
    public String getUser(){
        log.info("GET");
        return "GET-张三";
    }

    //保存用户 POST
    //@RequestMapping(value = "/user",method = RequestMethod.POST)
    @PostMapping("/user")
    public String saveUser(){
        log.info("POST");
        return "POST-张三";
    }

    //修改用户 PUT
    //@RequestMapping(value = "/user",method = RequestMethod.PUT)
    @PutMapping("/user")
    public String putUser(){
        log.info("PUT");
        return "PUT-张三";
    }

    //删除用户 DELETE
    //@RequestMapping(value = "/user",method = RequestMethod.DELETE)
    @DeleteMapping("/user")
    public String deleteUser(){
        log.info("DELETE");
        return "DELETE-张三";
    }
}

